#ifndef CONTROL_H
#define CONTROL_H
#include "zf_common_headfile.h"


typedef enum
{
		CONTROL_MODE_SPEED = 0,      		// 速度环模式 默认向前速度恒定
    CONTROL_MODE_POSITION ,    			// 位置环模式  debug 使用
		CONTROL_MODE_POSITION_SPEED,		//位置 速度串级
	
		CONTROL_MODE_STOP,        	 	// 停止模式 	默认车子无力状态
} 	Control_Speed_Mode_t;

typedef enum
{
		CONTROL_MODE_ANGLE_OUTER,				//imu 外环
		CONTROL_MODE_ANGLE_INTER,				//imu 内环
		CONTROL_MODE_ANGLE , 						// 角度环模式 默认车子保持0° 向3号电机的位置是+															
		CONTROL_MODE_TRACK,						// 巡线模式   默认车子向前巡线
}Control_Steer_Mode_t;
typedef struct CONTROL_TASK
{
		uint8_t task1_start_flag;
	  uint8_t task2_start_flag;
	  uint8_t task3_start_flag;
	  uint8_t task4_start_flag;
		
		uint8_t task1_flag;
		uint8_t task2_flag;
		uint8_t task3_flag;
		uint8_t task4_flag;
		
		uint8_t moter_stop_flag;
	
		uint8_t task_state;
}CONTROL_TASK;

typedef struct CONTROL_PARMER
{
	float Speed_base;//车子的基准速度
	float moter1_target_position;
	float moter2_target_position;
	float moter3_target_position;
	
	float moter1_target_speed;
	float moter2_target_speed;
	float moter3_target_speed;
	
	float moter_target_angle;
	float moter_target_Gyro_z;
	
	
	float imu_k;
	float speed_k;
	
}Control_Parm;
typedef enum CONTROL_POSITION_DIR
{
	FORW=0,
	BACK,
}CONTROL_POSITION_DIR	;



extern Control_Speed_Mode_t control_speed_mode;
extern Control_Steer_Mode_t control_steer_mode;
extern CONTROL_TASK control_flag;
extern Control_Parm control_param;
extern float car_distance;


void Control_init();
float Get_distence();
void Encoder_distance_clear();
void Control_position_solve(CONTROL_POSITION_DIR dir,float distance);
void Control_Speed_solve(float vx,float vy);
void Control_Position_solve(float x,float y);
void TASK_2025();

#endif // !CONTROL_H
